package com.yanqingshan.platform.common.core.convert;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yanqingshan.platform.common.core.domain.BasePageList;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

/**
 * 功能描述:
 *
 * @author yanqs
 * @since 2023-05-15
 */
@Mapper
public interface BasePageListConvert {

    BasePageListConvert INSTANCE = Mappers.getMapper(BasePageListConvert.class);

    default BasePageList convert(Page page) {
        BasePageList result = new BasePageList();
        result.setPage(page.getCurrent());
        result.setRows(page.getRecords());
        result.setTotal(page.getTotal());
        result.setPageSize(page.getSize());
        return result;
    }
}
